package com.example.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebMVCConfig implements WebMvcConfigurer {
    @Autowired
    private StringRedisTemplate template;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addPathPatterns为拦截途径，excludePathPatterns为放行路径
        //addInterceptor注册拦截器
        registry.addInterceptor(new UserIntercetor(template))
                .addPathPatterns("/page/**","/book/**")
                .excludePathPatterns("/login.html","/register.html","/user/**","error/**");
    }
}
